<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorator="layout/tpl">
<head>
    <meta charset="UTF-8"/>
    <title>添加角色</title>
    <style>
        form {
            padding: 10px;
        }
    </style>
</head>
<body layout:fragment="content">
<form class="layui-form  layui-form-pane">
    <div class="layui-form-item">
        <label class="layui-form-label">名称</label>
        <div class="layui-input-block">
            <input type="text" id="item" name="item" lay-verify="required|rolename" autocomplete="off" placeholder="请输入名称" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">描述</label>
        <div class="layui-input-block">
            <input type="text" id="description" name="description" autocomplete="off" placeholder="请输入描述" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item" pane="">
        <label class="layui-form-label">是否可用</label>
        <div class="layui-input-block">
            <input type="checkbox" id="available" checked="" name="open" lay-skin="switch" lay-filter="available" lay-text="ON|OFF">
        </div>
    </div>
    
</form>
</body>
<script type="text/javascript" layout:fragment="myscript">
    var available = true;
    layui.use('form', function(){
        form = layui.form;
        form.on('switch(available)' , function(data){
            available = data.elem.checked;
        });
    });
</script>
</html>